package bcc.java8.chap01.exe02;

import bcc.java8.chap02.exe01.Apple;

import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;

/**
 * @author bcc
 * @Description:
 * @date 2019-09-17 22:53
 */
public class StreamTest {
    public static void main(String[] args) {
        List<Apple> inventory = Arrays.asList(new Apple(80,"green"),
                new Apple(155, "green"),
                new Apple(120, "red"),
                new Apple(200, "green"),
                new Apple(188, "red"));

        //顺序处理
        List<Apple> heavyApples = inventory.stream().filter((Apple a) -> a.getWeight() > 150).collect(Collectors.toList());
        System.out.println(heavyApples);
        //并行处理
        List<Apple> heavyApples2 = inventory.parallelStream().filter((Apple a) -> a.getWeight() > 150).collect(Collectors.toList());
        System.out.println(heavyApples2);
    }
}
